﻿using System;
using System.Collections.Generic;
using System.Text;
using NLBS.Entity;
using NLBS.Framework;

namespace NLBS.Data.Business
{
    public class DefaultArticlePageHelp : BasePageHelp<Article>
    {
        #region IPageCache Members


        public DefaultArticlePageHelp(PageSetting Setting)
        {
            this.Setting = Setting;
        }

        public DefaultArticlePageHelp(PageSetting settings, string key)
       {
           this.Setting = settings;
           this.CacheKey = key;
       }

        public override void AddCacheKey()
        {

            CheckSetting();
            for (int i = Setting.Start; i <= Setting.End; i++)
            {
                int artID=PageList[i - Setting.Start].ArticleID;
                if (artID>0)
                {
                    KeyList[i] = artID;
                }
            }
        }

        public override void AddCacheEntity()
        {
            foreach (Article item in PageList)
            {
                cache.Insert(string.Format(Setting.Replicekey, item.ArticleID), item, CacheDuration.Long);
            }
        }

        #endregion

    }
}
